@extends("h5.layouts.main")
@section('content')
    <link rel="stylesheet" type="text/css" href="../css/app.css">
    <link rel="stylesheet" type="text/css" href="../css/order.css">

    <?php
    use App\Models\Admin\OrderBaleModel;
    use App\Models\Admin\OrderTempModel;
    use App\Models\CompanysModel;


    ?>
    <!----------抢单详情页面---------->
    <div id="orderParamPage">
        <div id="orderParamTitle">
            <b>公司订单参数</b>
            <img src="../images/return.png" id="orderRtn">
        </div>
        <div style="height:1.066667rem"></div>
        <div id="orderParamAddress">
        </div>
        <div id="orderParamIntro">
        </div>
        <div id="orderParamList">
            <p class="title">订单详情</p>
            <ul class="content orderParamList">


            </ul>
        </div>
        <div id="orderParamBtn">
            <p class="none">订单的30%作为保证金额度</p>
            <div class="button">
                <div class="apply none">支付抢单保证金</div>
                <?php


                ?>

                <div class="submit qiangdan none">立即抢单</div>
            </div>
        </div>
    </div>
    <!----------订单参数页面---------->

    <!----------错误提示---------->
    <div id="errMsg"></div>
    <!----------错误提示---------->
    </body>
    <script type="text/javascript" src="../js/getPageId.js"></script>
    <script type="text/javascript" src="../js/app.js"></script>
    <script type="text/javascript" src="../js/orderPageChange.js"></script>
    <script type="text/javascript" src="../js/order.js"></script>
    <script type="text/javascript" src="../js/alertMsg.js"></script>

    <script>
        var id = localStorage.getItem('orderShowId');
        var userInfo = JSON.parse(localStorage.getItem('userInfo'));
        var app_access = userInfo.app_access;
        var token = userInfo.token;

        function confirmOrder() {
            var data = {
                id: pageId,
                app_access: app_access,
                token: token
            }
            $.ajax({
                url: '/api/order/bale/confirm-graporder',
                data: data,
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    if (data.code < 0) {
                        alertMsg(data.msg)
                    } else {
                        alertMsg(data.msg)
                        window.location.href = 'orderDocking.html'
                    }
                },
                err: function (err) {
                    alertMsg(err)
                }
            })
        }

        function payOrder() {
            var data = {
                id: pageId,
                app_access: app_access,
                token: token
            }
            $.ajax({
                url: '/api/order/bale/payorder',
                data: data,
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    if (data.code == 0) {
                        window.location.href = 'orderPayType.html?id=' + pageId
                    } else {
                        alertMsg(data.msg)
                    }
                },
                err: function (err) {
                    alertMsg(err)
                }
            })
        }

        $('#orderRtn').on('click', function () {
            window.location.href = 'orderShow.html?id=' + pageId
        })
        $(function () {
            getOrderId();
            var bond = 0

            function getOrderId() {
                var data = {
                    out_trade_no: MC.get('out_trade_no'),
                    app_access: app_access,
                    token: token
                }
                //   $('.qiangdan').show();


                $('.qiangdan').click(function () {
                    MC.msg.confirm("将支付¥" + bond + "元保证金,是否继续?", function () {
                        MC.click(function () {
                            MC.api('ConfirmPayOrder', {
                                out_trade_no: MC.get('out_trade_no'),
                                notes: $('.bz').val()
                            }, function (json) {
                                // console.log(json);
                                window.open('/h5/order/orderDocking.html?out_trade_no=' + json.out_trade_no, '_self');
                            });
                        });
                    });
                    /// window.open('/h5/order/orderPayType','_self');


                });


                $.ajax({
                    url: '/api/order/bale/grapdetail2',
                    data: data,
                    type: 'post',
                    dataType: 'json',
                    success: function (data) {
                        var item = data.data;
                        if (data.code != 0) {
                            alertMsg(data.msg)
                        }
                        addressHtml = "<div class=\"nameAndPhone\"><div><span class=\"title\">抢单定位:</span><span class=\"content\">" + item.factory.com_name + "</span></div>";
                        if (item.factory.com_tel) {
                            addressHtml += "<div>" + item.factory.com_tel + "</div></div>";
                        }

                        addressHtml += "<div class=\"address\"><span class=\"title\">单位地址:</span><span class=\"content\">" + item.factory.com_address + "</span></div>";
                        $("#orderParamAddress").html(addressHtml);

                        infoHtml = "<div class=\"img\"><img src=" + item.img + "></div>" +
                            "<div class=\"content\">" + item.detail + "</div>";
                        $("#orderParamIntro").html(infoHtml);
                        listHtml = "<li>\n" +
                            "                    <span>订单数量</span>\n" +
                            "                    <div>" + item.num + "件</div>\n" +
                            "                </li>\n" +
                            "                <li>\n" +
                            "                    <span>订单金额</span>\n" +
                            "                    <div>￥" + item.money + "元</div>\n" +
                            "                </li>\n" +
                            "                <li>\n" +
                            "                    <span>所需保证金</span>\n" +
                            "                    <div>￥" + item.bond + "元</div>\n" +
                            "                </li>\n" +
                            "                <li>\n" +
                            "                    <span>厂家备注</span>\n" +
                            "                    <div><input type=\"text\" class=\"bz\" value='" + item.notes + "' placeholder=\"请填写备注\"></div>\n" +
                            "                </li>\n" +
                            "                <li>\n" +
                            "                    <span>下单时间</span>\n" +
                            "                    <div>" + item.createTime + "</div>\n" +
                            "                </li>\n";
                        /*
                                                "                <li>\n" +
                                                "                    <span>快递运单</span>\n" +
                                                "                    <div>"+item.orderNo+"</div>\n" +
                                                "                </li>\n" +
                                                "                <li>\n" +
                                                "                    <span>快递类型</span>\n" +
                                                "                    <div>"+item.orderTypeName+"</div>\n" +
                                                "                </li>";*/
                        $(".orderParamList").html(listHtml);
                        bond = item.bond;
                        $('.qiangdan').show();


                    },
                    err: function (err) {
                        alertMsg(err)
                    }
                })
            }
        })
    </script>













    <?php
    $user = App\admin\Service\OA::$user->getModel();

    ?>



@stop